package com.engine4cloud.tdf.supervision.controller.inner;

import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.data.web.response.PageInfo;
import com.engine4cloud.tdf.common.log.annotation.SysLog;
import com.engine4cloud.tdf.common.security.annotation.Inner;
import com.engine4cloud.tdf.supervision.dto.DcpgEvaluateDTO;
import com.engine4cloud.tdf.supervision.dto.query.DcpgInvestigationQueryDTO;
import com.engine4cloud.tdf.supervision.dto.result.DcpgInvestigationResultDTO;
import com.engine4cloud.tdf.supervision.service.DcpgInvestigationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

/**
 * 调查评估-委托-inner
 *
 * @author wenjie
 * @date 2024-07-29 18:04:50
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/inner/investigation")
@Tag(description = "InvestigationWeb", name = "调查评估-委托-inner")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class DcpgInvestigationInnerController {

    private final DcpgInvestigationService dcpgInvestigationService;

    /**
     * 分页查询
     *
     * @param dto 调查评估-委托-请求对象
     * @return R<PageInfo < DcpgInvestigationResultDTO>>
     */
    @Inner
    @Operation(summary = "分页查询", description = "分页查询")
    @PostMapping("/page")
    public R<PageInfo<DcpgInvestigationResultDTO>> getInvestigationPage(@Valid @RequestBody DcpgInvestigationQueryDTO dto) {
        return R.ok(dcpgInvestigationService.pageList(dto));
    }

    /**
     * 通过id查询调查评-委托信息
     *
     * @param id id
     * @return R
     */
    @Inner
    @Operation(summary = "通过id查询", description = "通过id查询")
    @GetMapping("/{id}")
    public R<DcpgInvestigationResultDTO> getById(@PathVariable("id") Long id) {
        return R.ok(dcpgInvestigationService.getById(id));
    }

    /**
     * 调查评估-结果意见（所填写）
     *
     * @param dto 调查评估-结果意见（所填写）
     * @return R 权限：和编辑是一个权限
     */
    @Inner
    @Operation(summary = "调查评估-结果意见（所填写）", description = "调查评估-结果意见（所填写）")
    @SysLog("调查评估-结果意见")
    @PutMapping("/evaluate")
    public R<Boolean> evaluate(@Valid @RequestBody DcpgEvaluateDTO dto) {
        return R.ok(dcpgInvestigationService.evaluate(dto));
    }
}